import request from '@/utils/request';
import {object2Url} from "@/utils/trans";

// 商家监控设备查询”
export async function queryMerchantList (data) {
  const res = await request.post('/business/deviceInformation/agentSelectPage', data)
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

 // 创建成片任务 1
export async function createFragmentedTask (data) {
  const res = await request.post('/business/chipConfiguration/createFragmentedTask', data)
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 创建成片任务_采集列表数据 2
export async function publishTask (data) {
  const res = await request.post('/business/collectionTask/cameraAcquisitionTask', data)
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



// 加载剪辑工程Ai配置
export async function loadAiConfigByProjectId (data) {
  const res = await request.post('/business/montage/aiconfig/loadAiConfigByProjectId', data)
  if (res.data.code === 2000) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.msg))
}
//获取AI配置
export async function aiConfig(data) {
  const res = await request.post('/business/montage/ailist/aiConfig', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


export async function largeAccountToken () {
  const ts = new Date().getTime()
  const ua = navigator.userAgent
  const us = {
    ts,
    ua,
    code: '00dce5f9eeca5551sayoJfDQtbnl6PVHP0Em',
    id:Number(23)
  }
  // eslint-disable-next-line no-undef

  // let url = `/business/mobile/accountToken{object2Url(us)}`
  let url = `/business/mobile/largeAccountToken${object2Url(us)}`
  const res = await request.get(url, us)
  if (res.data.code === 2000) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.msg))
}

// 查询oem，发布视频点数
export async function queryOemPoint(data) {
  const res = await request.post('/business/MerchantManagement/merchantCof', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 获取所有AI
export async function aiListAll () {
  const ts = new Date().getTime()
  const ua = navigator.userAgent
  const us = {
    ts,
    ua
  }
  // eslint-disable-next-line no-undef
  let url = `/business/montage/ailist/list${object2Url(us)}`
  const res = await request.get(url, us)
  if (res.data.code === 2000) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.msg))
}

